home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / FD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1.2 KB  |  50 lines

  1. /* fd.c - FD program - main function */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewcmds.h"
  5. #include "fdparm.h"
  6.  
  7. char filename[65] = "" ;
  8.  
  9. main(argc,argv)
  10.   int argc ;
  11.   char *argv[] ;
  12.   {
  13.      int cmd ;                /* holds current command */
  14.  
  15.      if( argc >= 2 )            /* get file name from command */
  16.     strcpy(filename,argv[1] ) ;    /* line ( if present ) */
  17.  
  18.  
  19.      get_filename(filename) ;        /* get filename and open file */
  20.      set_filesize(BIN_MODE) ;        /* set up filesize variable */
  21.      cmd = FIRSTPAGE  ;         /* force display to first page */
  22.  
  23.  
  24.      while( cmd != EXITPGM )        /* repeat until told to exit */
  25.     {  exec_cmd( cmd ) ;        /* execute the current command */
  26.        cmd = get_cmd() ;        /* get the next command */
  27.     }
  28.  
  29.      close_file() ;
  30.   }
  31.  
  32. int get_filename(fn)            /* get name of file and open it */
  33.   char fn[] ;                /* file name string  */
  34.   {                    /* filled out by caller */
  35.      if ( strlen(fn) == 0 )
  36.     {  printf("file name:") ;
  37.        scanf("%s",fn) ;
  38.     }
  39.  
  40.      while( open_file(fn) == FAILURE )    /* open the file (verify name) */
  41.     {  printf("\n file - %s can not be opened \n") ;
  42.        printf("file name:") ;       /* try again */
  43.        scanf("%s",fn)  ;
  44.     }
  45.   }
  46.  
  47.  
  48.  
  49.  
  50.